package master.userInterface;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;


import master.Workspace;
import master.quantumComputerIO.gate.*;

public class WorkspacePanel extends JPanel{
	private final Workspace myWorkspace;
	public WorkspacePanel(Workspace myWorkspace){
		this.myWorkspace = myWorkspace;
		this.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.weighty = 1;
		c.weightx = 1;
		c.fill = GridBagConstraints.BOTH;
		c.gridy = 0;
		c.gridx = 0;
		JPanel qReg = myWorkspace.getWorkingNetwork().getOutputRegister().QMDisplay();
		qReg.setMinimumSize(new Dimension(450,200));
		
		JPanel netwk = new NetworkDisplayPanel(myWorkspace.getWorkingNetwork());
		
		
		JPanel script = new NetworkScriptPanel(myWorkspace.getWorkingNetwork());
		
		
		JPanel menu = new JPanel();
		try{
			QuantumGateFactory [] qgf =
				QuantumGateFactory.factoriesForClasses(QuantumGateIO.getGatesFromPackageStable());
			GateIOPanel [] giop = GateIOPanel.panelsForGates(qgf);
			menu = new GateMenuPanel(new GateComboBox(giop),myWorkspace.getWorkingNetwork());
		}catch(GateException e){
			
		}
		
		/*
		GateMenuPanel menu = QuantumGateIO.getProjectGateMenu();
		menu.addGateGenerationListener(myWorkspace.getWorkingNetwork());
		menu.setPreferredSize(new Dimension(200,200));*/
		
		JSplitPane networkSP = new JSplitPane(JSplitPane.VERTICAL_SPLIT,netwk,
				script );
		
		JSplitPane qRegVMenu = new JSplitPane(JSplitPane.VERTICAL_SPLIT,menu,qReg);
		
		JSplitPane two = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,qRegVMenu,networkSP);
		
		
		this.add(two,c);
	}
	public Workspace getWorkspace(){
		return myWorkspace;
	}
}
